/*
 * @Date: 2022-03-30 11:40:28
 * @LastEditors: LiuPeng
 * @LastEditTime: 2022-04-11 09:27:48
 * @LastEditors: LiuPeng
 * @LastEditTime: 2022-04-02 10:37:40
 * @FilePath: \pay\src\components\Modal\index.jsx
 * @Description: 查看代付订单模态框
 * 
 */

import React, { useState, useEffect } from "react";
import { Modal, Button } from 'antd';

import Tabs from '../Tabs'


export default function MyModal(props) {

  // console.log(props);
  let { showmodal } = props
  let [modal2Visible, setModal2Visible] = useState(false)

  // showmodal = showmodal === 'true' ? true : false 

  const setModalVisible = (modal2Visible) => {
    // console.log();
    setModal2Visible(modal2Visible)
  }
  // console.log(props);

  let { btntext, title, selecedstatus } = props

  useEffect(() => {
    if (showmodal === 'false') {
      setModal2Visible(false)
    }
  }, [showmodal])
  return (
    <>
      <Button {...props} onClick={() => {
        if (btntext !== '编辑') {
          // console.log('编辑点击事件');
          setModalVisible(true)
        } else {
          if (selecedstatus === 'true') {
            setModalVisible(showmodal)
          }
        }
      }

      }>
        {btntext}
      </Button>
      <Modal
        title={title}
        centered
        width={1000}
        visible={modal2Visible}
        onOk={() => setModalVisible(false)}
        onCancel={() => setModalVisible(false)}

      >
        {/* 标题 */}
        <Tabs title='基本信息' />
        {/* 展示信息 */}
        {props.children}
      </Modal>
    </>
  )
}
